package com.harmonyos.service.impl;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.harmonyos.domain.TbFourm;
import com.harmonyos.domain.TbNews;
import com.harmonyos.mapper.TbNewsMapper;
import com.harmonyos.service.TbNewsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TbNewsServicelmpl  extends ServiceImpl<TbNewsMapper, TbNews> 
        implements TbNewsService {
    @Resource
    private TbNewsMapper tbNewsMapper;


    @Override
    public String selectAll() {
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        try {
            LambdaQueryWrapper<TbNews> wrapper = new LambdaQueryWrapper<>();
            List<TbNews> tbNews = tbNewsMapper.selectList(wrapper);
            objectObjectHashMap.put("data",tbNews);
            objectObjectHashMap.put("code","200");
        } catch (Exception e) {
            objectObjectHashMap.put("code","500");
            e.printStackTrace();
        }
        return JSONUtil.toJsonStr(objectObjectHashMap);
    }
}
